tsset ctyind year
rename en_int enint
/* Following 22 lines create a balanced panel by adding in State-Ind observations with zero employment( There are no State-Ind observations in 
years for which there is zero employment so I create the observations and generate the variables in the regression)*/
tsfill, full
bysort ctyind:carryforward naics,replace
bysort ctyind:carryforward fipstate,replace
bysort ctyind:carryforward NBP,replace
bysort ctyind:carryforward enint,replace
bysort ctyind:carryforward nonattainCO,replace
bysort ctyind:carryforward nonattainOZ,replace
bysort ctyind:carryforward nonattainPM,replace


gsort ctyind - year
bysort ctyind:carryforward naics,replace
bysort ctyind:carryforward fipstate,replace
bysort ctyind:carryforward NBP,replace
bysort ctyind:carryforward enint,replace
bysort ctyind:carryforward nonattainCO,replace
bysort ctyind:carryforward nonattainOZ,replace
bysort ctyind:carryforward nonattainPM,replace


drop yearind post NBP postxNBP postxint intxNBP postxNBPxint
tostring year,replace
gen STyear=fipstate+year
gen yearind=year+naics
destring year,replace

destring fipstate,gen(fipsnum)
gen post=1 if inlist(year,2005,2006,2007,2008,2009)
gen NBP=1 if inlist(fipsnum,1,9,10,11,17,18,19,21,23,24,25,26,27,33,34,36,37,38,39,42,44,45,47,50,51,54,55)
replace NBP=0 if NBP==.
replace post=0 if post==.
replace post=1 if year==2004 & inlist(fipsnum,9,10,11,23,24,25,33,34,36,42,44,50)
drop if fipsnum==29
replace enint=0 if enint==.
gen postxNBP=post*NBP
gen postxint=post*enint
gen intxNBP=enint*NBP
gen postxNBPxint=post*NBP*enint

replace postxNAxint=post*nonattainOZ*enint

replace emp_imp=1 if emp_imp==.
replace lemp_imp=1 if lemp_imp==.
